package control.MIC;

import java.util.ArrayList;
import java.util.List;

import algorithm.SAElem;
import control.ComponentInfo;
import control.SAModifier;
import control.ExeCtx;
import control.ISAMdlInfo;

public class MICCtrlEngHelper extends SAModifier implements ISAMdlInfo {

	public MICCtrlEngHelper(ExeCtx exeCtx) {
		super(exeCtx);
		 exeCtx.setSaInfo(this);
	}



	public ArrayList<SAElem> getChgedElems(List<StringBuffer> codes) {
		ArrayList<SAElem> chgedElems = new ArrayList<SAElem>();
		// 处理速度変更元素
		SAElem saElem = new SAElem();
		saElem.setDoFID("1");
		saElem.setElemName("server1_CPU_speed");
		saElem.setValue(codes.get(0).toString());
		chgedElems.add(saElem);

		SAElem saElem1 = new SAElem();
		saElem1.setDoFID("1");
		saElem1.setElemName("server2_CPU_speed");
		saElem1.setValue(codes.get(1).toString());
		chgedElems.add(saElem1);

		SAElem saElem2 = new SAElem();
		saElem2.setDoFID("1");
		saElem2.setElemName("server3_CPU_speed");
		saElem2.setValue(codes.get(2).toString());
		chgedElems.add(saElem2);

		SAElem saElem3 = new SAElem();
		saElem3.setDoFID("1");
		saElem3.setElemName("server4_CPU_speed");
		saElem3.setValue(codes.get(3).toString());
		chgedElems.add(saElem3);

		// 组件部署変更
		SAElem saElem9 = new SAElem();
		saElem9.setDoFID("3");
		saElem9.setElemName("Webserver_Dep");
		saElem9.setValue(codes.get(4).toString());
		chgedElems.add(saElem9);

		SAElem saElem10 = new SAElem();
		saElem10.setDoFID("3");
		saElem10.setElemName("Scheduler_Dep");
		saElem10.setValue(codes.get(5).toString());
		chgedElems.add(saElem10);

		SAElem saElem11 = new SAElem();
		saElem11.setDoFID("3");
		saElem11.setElemName("DB_Dep");
		saElem11.setValue(codes.get(6).toString());
		chgedElems.add(saElem11);

		SAElem saElem12 = new SAElem();
		saElem12.setDoFID("3");
		saElem12.setElemName("ReportingEngine_Dep");
		saElem12.setValue(codes.get(7).toString());
		chgedElems.add(saElem12);

		SAElem saElem13 = new SAElem();
		saElem13.setDoFID("3");
		saElem13.setElemName("CacheInfo_Dep");
		saElem13.setValue(codes.get(8).toString());
		chgedElems.add(saElem13);

		SAElem saElem14 = new SAElem();
		saElem14.setDoFID("3");
		saElem14.setElemName("GraphicalReporting_Dep");
		saElem14.setValue(codes.get(9).toString());
		chgedElems.add(saElem14);

		SAElem saElem15 = new SAElem();
		saElem15.setDoFID("3");
		saElem15.setElemName("OnlineReporting_Dep");
		saElem15.setValue(codes.get(10).toString());
		chgedElems.add(saElem15);

		SAElem saElem16 = new SAElem();
		saElem16.setDoFID("3");
		saElem16.setElemName("UserManagement_Dep");
		saElem16.setValue(codes.get(11).toString());
		chgedElems.add(saElem16);

		SAElem saElem17 = new SAElem();
		saElem17.setDoFID("3");
		String name = codes.get(12).toString();
		saElem17.setElemName("CoreEngine_" + name);
		saElem17.setValue(name);
		chgedElems.add(saElem17);

		// 组件选择変更
		SAElem saElem19 = new SAElem();
		saElem19.setDoFID("2");
		String cmpName = codes.get(13).toString();
		saElem19.setElemName("WebServer_" + cmpName);
		saElem19.setValue(cmpName);
		chgedElems.add(saElem19);

		return chgedElems;
	}
	@Override
	public ArrayList<String> getServerNames() {
		ArrayList<String> serverNms = new ArrayList<String>();
		serverNms.add(new String("server1"));
		serverNms.add(new String("server2"));
		serverNms.add(new String("server3"));
		serverNms.add(new String("server4"));
		return serverNms;
	}

	/**
	 * 获取初始编码
	 * 
	 * @return
	 */
	@Override
	public List<StringBuffer> getInitFdCodes() {
		List<StringBuffer> fdCodes = new ArrayList<StringBuffer>();
		for (int i = 0; i < 4; i++) {
			float procSpd = 10.0f;
			StringBuffer spd = new StringBuffer(String.valueOf(procSpd));
			fdCodes.add(spd);
		}
		fdCodes.add(new StringBuffer("server1"));
		fdCodes.add(new StringBuffer("server2"));
		fdCodes.add(new StringBuffer("server3"));
		fdCodes.add(new StringBuffer("server4"));
		fdCodes.add(new StringBuffer("server4"));
		fdCodes.add(new StringBuffer("server2"));
		fdCodes.add(new StringBuffer("server2"));
		fdCodes.add(new StringBuffer("server2"));
		fdCodes.add(new StringBuffer("server4"));
		fdCodes.add(new StringBuffer("WebServer"));

		return fdCodes;
	}

	/**
	 * 获取组件名字列表
	 */
	@Override
	public List<String> getInitCompNames() {
		List<String> compNames = new ArrayList<String>();
		compNames.add("Webserver");
		compNames.add("Scheduler");
		compNames.add("DB");
		compNames.add("ReportingEngine");
		compNames.add("CacheInfo");
		compNames.add("GraphicalReporting");
		compNames.add("OnlineReporting");
		compNames.add("UserManagement");
		compNames.add("CoreReportingEngine");
		return compNames;
	}

	/**
	 * 获取组件实例的部署列表
	 */
	@Override
	public ArrayList<String> getEntityACName() {
		ArrayList<String> entityACNames = new ArrayList<String>();
		entityACNames.add("Allocation_AC_Webserver <WebServer>");
		entityACNames.add("Allocation_AC_Scheduler <Scheduler>");
		entityACNames.add("Allocation_AC_DB <DB>");
		entityACNames.add("Allocation_AC_ReportingEngine <ReportingEngine>");
		entityACNames.add("Allocation_AC_CacheInfo <CacheInfo>");
		entityACNames.add("Allocation_Assembly_GraphicalReporting <GraphicalReporting> <GraphicalReporting>");
		entityACNames.add("Allocation_Assembly_OnlineReporting <OnlineReporting> <OnlineReporting>");
		entityACNames.add("Allocation_AC_UserManagement <UserManagement> <UserManagement>");
		entityACNames.add("Allocation_Assembly_CoreReportingEngine2_gr <CoreReportingEngine2> <CoreReportingEngine2>");
		return entityACNames;
	}


	/**
	 * 获取可被选择的组件名字列表
	 * @return
	 */
	@Override
	public ArrayList<ArrayList<String>> getSelCompNmList() {
		ArrayList<ArrayList<String>> selCompNmList = new ArrayList<ArrayList<String>>();
		ArrayList<String> compNms = new ArrayList<String>();
		compNms.add("WebServer");
		compNms.add("WebServer2");
		compNms.add("WebServer3");
		selCompNmList.add(compNms);
		return selCompNmList;
	}



	@Override
	public void mdfySA(List<StringBuffer> codes) {
		// TODO Auto-generated method stub
		
	}


}
